<nz-modal [(nzVisible)]="isVisible" [nzMaskClosable]="false" [nzTitle]="attachType" (nzOnCancel)="handleCancel()"
  nzWidth="850" [nzFooter]="footer">
  <!--附件选择-->
  <div *ngIf="!readOnly && isShow">
    <nz-upload [(nzFileList)]="fileList" [nzBeforeUpload]="beforeUpload" [nzMultiple]="true" [nzFilter]="filters">
      <button nz-button><em nz-icon nzType="upload"></em><span>选择文件</span></button>
    </nz-upload>
  </div>
  <br />

  <nz-table nzBordered [nzShowPagination]="'false'" [nzData]="attachFiles" #auditProjectAttach [nzSize]="'middle'"
    [nzTitle]="'已上传附件信息'" [nzScroll]="{ y: '100%' }" style="height:250px" class="scrollbar">
    <thead>
      <tr>
        <th style="width: 30%;" [nzAlign]="'center'">文件原名称</th>
        <th style="width: 30%;" [nzAlign]="'center'">文件存储名称</th>
        <th style="width: 15%;" [nzAlign]="'center'">文件格式</th>
        <th style="width: 25%;" [nzAlign]="'center'">操作</th>
      </tr>
    </thead>
    <tbody>
      <tr *ngFor="let data of attachFiles">
        <td style="width: 30%;" [nzAlign]="'center'">
          {{ data.originalName }}
        </td>
        <td style="width: 30%;" [nzAlign]="'center'">
          {{ data.name }}
        </td>
        <td style="width: 15%;" [nzAlign]="'center'">
          {{ data.type }}
        </td>
        <td style="width: 25%;" [nzAlign]="'center'">
          <div>
            <a (click)="download(data.id, data.originalName)">下载</a>
            <a *ngIf="readOnly" (click)="preview(data.id, data.originalName)">
              <nz-divider nzType="vertical"></nz-divider>预览
            </a>
            <nz-popconfirm [nzTitle]="'是否要删除此行数据？'" (nzOnConfirm)="deleteAttach(data)">
              <a *ngIf="isShow" nz-popconfirm>
                <nz-divider nzType="vertical"></nz-divider>删除
              </a>
            </nz-popconfirm>
          </div>
        </td>
      </tr>
    </tbody>
  </nz-table>
  <!--底部按钮-->
  <ng-template #footer>
    <div>
      <!--上传按钮-->
      <button nz-button [nzType]="'default'" [nzLoading]="uploading" (click)="handleUpload()"
        [disabled]="fileList.length == 0" *ngIf="isShow" style="margin-top: 16px">
        {{ uploading ? '正在上传' : '上传' }}
      </button>
      <button nz-button nzType="default" *ngIf="isShow && !readOnly" (click)="save()">保存</button>
      <button nz-button nzType="default" *ngIf="readOnly" (click)="back()">确认</button>
      <!-- <button nz-button nzType="default" *ngIf="isShow && !readOnly" (click)="handleCancel()">取消</button> -->
    </div>
  </ng-template>
</nz-modal>

<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null"
  (nzOnCancel)="previewVisible = false">
  <ng-template #modalContent>
    <img [src]="previewImage" [ngStyle]="{ width: '100%' }" />
  </ng-template>
</nz-modal>
